
var newTable={
	 init : function() {
		
		//获取驱动列表
		newTable.loadTableDrivers();
    },
	
	loadTableDrivers:function(){ 
		var params = {
					"to":"tableManage",	
					"msgId":"getTableTypes",
					"msg":{
						}
					};
		
		$.post("/watchDog/database/handleManage.req",JSON.stringify(params),function(result){
			result = result.replace(/\n/g," ");
			result = result.replace(/\r/g," ");
			var data = $.parseJSON(result);   
			
			if(!DealErrorInfo(data,'获取设备信息失败：')){	 
				return ;
			}						
			
			var tableDrvs = data.msg.tableDrvs;
			$("#tableDrivers").html("");
			var selected = "selected=\"selected\""
			for(var i=0;i<tableDrvs.length;i++)
			{
				var info = tableDrvs[i];
				$("#tableDrivers").append("<option value=\""+info.deviceId+"\" "+selected+">"+info.name+"-" + info.version+"</option>");	
				selected = "";
			}
			
		}).fail(function(){
			$("#sessions").html("连接服务器失败");
		});
	},
	
	addNewTable:function()
	{
		var tableName = $("#tableName").val();
		tableName = $.trim(tableName);
		if(tableName == "")
		{
			alert("请输入数据库表名");
			return;
		}
		
		var tableDriver = $("#tableDrivers").val();
		//alert("tableDriver:"+tableDriver+",tableName:" + tableName);
		
		//
		var params = {
					"to":"tableManage",	
					"msgId":"createTable",
					"msg":{
						"tableDriver":tableDriver,
						"tableName":tableName,
						"coding":2
						}
					};
		
		$.post("/watchDog/database/handleManage.req",JSON.stringify(params),function(result){
				//alert(result);
		}).fail(function(){
			$("#sessions").html("连接服务器失败");
		});
	},
}